/*

myXMLLoader.addEventListener("onFileLoad", this);

*/

import mx.events.EventDispatcher;
class com.Lithyem.XMLLoader extends Object{
	
	var addEventListener:Function;
	var removeEventListener:Function;
	var dispatchEvent:Function;
	
	var xmldata:XML;
	
	function XMLLoader(){
		mx.events.EventDispatcher.initialize(this);
		
		var host:Object = this;
		
		xmldata = new XML();
		xmldata.ignoreWhite = true;
		xmldata.onLoad = function(success:Boolean):Void{
			host.onLoadComplete(success);
		}
	}

	function onLoadComplete(success:Boolean):Void{
		if(success){
			onFileLoad();
		}else{
			onFileError();
		}
	}

	function onFileLoad():Void{
		var evtObj:Object = {target:this,type:"onFileLoad"};
		evtObj.data = xmldata;
		dispatchEvent(evtObj);
	}
	
	function onFileError():Void{
		var evtObj:Object = {target:this,type:"onFileError"};
		evtObj.data = xmldata;
		dispatchEvent(evtObj);
	}
	
	function loadFile(df:String):Void{
		xmldata.load(df);
	}

}